package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.enums.ErrorCodeEnum;
import com.csun.cmny.provider.exceptions.OmcBizException;
import com.csun.cmny.provider.model.dto.attachment.OptAttachmentRespDto;
import com.csun.cmny.provider.model.dto.oss.OptGetUrlRequest;
import com.csun.cmny.provider.model.vo.VolunteerVo;
import com.csun.cmny.provider.service.OpcOssFeignApi;
import com.csun.cmny.provider.service.OpcRpcService;
import com.csun.cmny.provider.vo.OrderServiceItemVo;
import com.csun.cmny.util.wrapper.Wrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
@Component
public class OpcRpcServiceImpl implements OpcRpcService {

    @Resource
    private OpcOssFeignApi opcOssFeignApi;

    @Override
    public List<OptAttachmentRespDto> queryAttachmentById(List<Long> urls) {
        try {
            Wrapper<List<OptAttachmentRespDto>> wrapper = opcOssFeignApi.queryAttachmentById(urls);
            if (wrapper == null) {
                throw new OmcBizException(ErrorCodeEnum.GL99990002);
            }
            if (wrapper.error()) {
                throw new OmcBizException(ErrorCodeEnum.OPC10040008);
            }
            List<OptAttachmentRespDto> result = wrapper.getResult();

            assert result != null;

            return result;

        } catch (Exception e) {
            log.error("queryAttachmentById={}", e.getMessage(), e);
        }

        return null;
    }

}
